package com.remembercard;

public class Deck {
	private Card[] deck;
	private int current;
	
	private String[] suits = {"corazon", "diamante", "pica", "trebol"};
	
	public Deck() {
		initDeck();
		shuffle();
		current = 0;
	}
	
	private void initDeck() {
		deck = new Card[52];
		
		for(int i = 0; i < 13; i++) {
			int curr = 0;
			for(String suit: suits) {
				deck[i * 4 + curr] = new Card(i + 1, suit, suits[curr].charAt(0) + String.valueOf(i + 1));
				curr++;
			}
		}

	}
	
	private void shuffle() {
		for(int i = 0; i < 100; i++) {
			int first = (int) (Math.random() * deck.length);
			int second = (int) (Math.random() * deck.length);
			Card aux = deck[first];
			deck[first] = deck[second];
			deck[second] = aux;
		}
	}

	public Card getNext() {
		if(hasNext()) {
			current++;
			return deck[current - 1];
		} return null;
	}
	
	public boolean hasNext() {
		return current < 52;
	}
	
}